package com.elbis.email.generator;

import java.util.Date;

public class ExpiryDateGenerator {

	private static final Long ONE_MINUTE = 60000L;
	private static final Long ONE_HOUR = ONE_MINUTE * 60;
	private static final Long ONE_DAY = ONE_HOUR * 24;

	private ExpiryDateGenerator() {
	}

	/**
	 * Generates a date exactly 24 hours from now.
	 * 
	 * @return tomorrow this time
	 */
	public static Date generateExpiryDate() {
		return new Date(System.currentTimeMillis() + ONE_DAY);
	}

	/**
	 * Generates a date exactly after given number of days. If the given number
	 * of days is negative or 0, it is adjusted to 1.
	 * 
	 * @param numOfDays
	 *            positive number of days from now on ahead
	 * @return numOfDays later this time
	 */
	public static Date generateExpiryDate(int numOfDays) {
		if (numOfDays <= 0) {
			return generateExpiryDate();
		}
		return new Date(System.currentTimeMillis() + (ONE_DAY * numOfDays));
	}

	/**
	 * Generates a delta in milliseconds from today.
	 * 
	 * @param numOfDays
	 * @return milliseconds representation for the number of days
	 */
	public static Long generateDeltaExpiryMillis(int numOfDays) {
		return ONE_DAY * numOfDays;
	}

}
